home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
IRIX Base Documentation 1998 November
/
IRIX 6.5.2 Base Documentation November 1998.img
/
usr
/
share
/
catman
/
p_man
/
cat3
/
f90
/
ffopen.z
/
ffopen
Wrap
Text File
|
1998-10-30
|
8KB
|
173 lines
FFOPEN(3C) Last changed: 2-5-98
NNAAMMEE
ffffooppeenn, ffffooppeennss, ffffcclloossee, ffffooppeennff, ffffcclloosseeff - Opens or closes a file
using flexible file I/O
SSYYNNOOPPSSIISS
##iinncclluuddee <<ffccnnttll..hh>>
##iinncclluuddee <<ffffiioo..hh>>
UNICOS and UNICOS/mk systems:
iinntt ffffooppeenn ((ccoonnsstt cchhaarr **_n_a_m_e,, iinntt _o_f_l_a_g [[,, iinntt _m_o_d_e
[[,, lloonngg _c_b_i_t_s [[,, ssttrruucctt ffffssww **_s_t_a_t]]]]]]));;
iinntt ffffooppeennss ((ccoonnsstt cchhaarr **_n_a_m_e,, iinntt _o_f_l_a_g,, iinntt _m_o_d_e,,
lloonngg _c_b_i_t_s,, [[iinntt _c_b_l_k_s,,]] ssttrruucctt ffffssww **_s_t_a_t,, ccoonnsstt cchhaarr **_s_t_r));;
ffffcclloossee ((iinntt _f_d [[,, ssttrruucctt ffffssww **_s_t_a_t]]));;
IRIX systems:
iinntt ffffooppeenn ((ccoonnsstt cchhaarr **_n_a_m_e,, iinntt _o_f_l_a_g [[,,mmooddee__tt _m_o_d_e]]));;
iinntt ffffooppeennss ((ccoonnsstt cchhaarr **_n_a_m_e,, iinntt _o_f_l_a_g,, mmooddee__tt _m_o_d_e,,
lloonngg _c_b_i_t_s, iinntt _c_b_l_k_s,, ssttrruucctt ffffssww **_s_t_a_t,, ccoonnsstt cchhaarr **_s_t_r));;
iinntt ffffcclloossee ((iinntt _f_d));;
All systems:
ffffcclloosseeff ((iinntt _f_d,, ssttrruucctt ffffssww **_s_t_a_t));;
iinntt ffffooppeennff ((ccoonnsstt cchhaarr **_n_a_m_e,, iinntt _o_f_l_a_g ,, iinntt ,,mmooddee__tt _m_o_d_e lloonngg
_c_b_i_t_s,, iinntt _c_b_l_k_s,, ssttrruucctt ffffssww **_s_t_a_t));;
IIMMPPLLEEMMEENNTTAATTIIOONN
UNICOS, UNICOS/mk, and IRIX systems
DDEESSCCRRIIPPTTIIOONN
The ffffooppeenn and ffffooppeennss functions open a file using flexible file I/O
(FFIO). These functions are modeled after the ooppeenn(2) system call.
The file associated with _n_a_m_e is opened, and appropriate structures
are built to do special handling on the file. For ffffooppeenn, the
processing layers to be used are as requested with the aassggccmmdd(1) or
aassssiiggnn(1) commands. For ffffooppeennss, the layers are specified by the
string at _s_t_r.
The ffffooppeenn function returns an integer. Although it is not a file
descriptor, it is used in much the same way when passed to the other
functions such as ffffrreeaadd, ffffwwrriittee, or ffffcclloossee.
The _o_f_l_a_g, _m_o_d_e, and _c_b_i_t_s parameters are exactly as in ooppeenn(2).
On IRIX systems, the _c_b_i_t_s and _c_b_l_k_s parameters are ignored.
The _s_t_a_t parameter is a pointer to a status return structure
containing a flag, an error indication, a transfer count, and an
indication of the condition that terminated the request.
The ffffcclloossee and ffffcclloosseeff functions close the file associated with _f_d.
It does any necessary flushing and termination for that file. Files
opened using ffffooppeenn(3C) are not guaranteed to be flushed at program
termination; call ffffcclloossee or ffffcclloosseeff to ensure this.
NNOOTTEESS
On IRIX systems, the FFIO routines are stored in lliibbffffiioo..ssoo, and are
available in the N32 and N64 ABIs.
RREETTUURRNN VVAALLUUEESS
Upon successful completion, a non-negative integer is returned; this
integer is currently a pointer to a control block. Otherwise, -1 is
returned, and, if the _s_t_a_t parameter is passed, the error value is
found in ssttaatt..ssww__eerrrroorr. If the _s_t_a_t parameter is not provided, the
error code is found in eerrrrnnoo. The _s_t_a_t parameter is required for
ffffooppeennss() and ffffcclloosseeff.
EEXXAAMMPPLLEESS
To write a C program that will read the records of a COS blocked file
named iinnddaattaa and copy the data from the file (without blocking
information) to ssttddoouutt, compile the following program:
#include <stdio.h>
#include <fcntl.h>
#include <ffio.h>
#define BSZ 10000
main()
{
int fd, ret;
char buf[BSZ];
struct ffsw stat;
int ubc = 0;
fd = ffopen("indata", O_RDONLY);
do
{
ret = ffreadf(fd, buf, BSZ, &stat, PARTIAL, &ubc);
fwrite(buf, 1, ret, stdout);
} while (FFSTAT(stat) != FFEOD);
ret = ffclose(fd);
}
Use the following commands to compile, link, and run this program on
UNICOS and UNICOS/mk systems:
$ cc cpy.c
$ eval `assign -F cos indata` # declare "indata" is COS blocked
$ a.out
Use the following commands to compile, link, and run this program on
IRIX systems:
$ cc cpy.c -lffio
$ eval `assign -F cos indata` # declare "indata" is COS blocked
$ a.out
The same example program could be written to use the ffffooppeennss entry
point. The layers to use in decoding the blocking information are
specified in the call, and not in the shell command aassggccmmdd(1), as
follows:
#include <stdio.h>
#include <fcntl.h>
#include <ffio.h>
#define BSZ 10000
main()
{
int fd, ret;
char buf[BSZ];
char *str;
struct ffsw stat;
int ubc = 0;
/* Set up to process COS blocked file. */
str = "cos";
fd = ffopens("indata", O_RDONLY, 0, 0L, 0, &stat, str);
do
{
ret = ffreadf(fd, buf, BSZ, &stat, PARTIAL, &ubc);
fwrite(buf, 1, ret, stdout);
} while (FFSTAT(stat) != FFEOD);
ret = ffclose(fd);
}
Use the following commands on UNICOS and UNICOS/mk systems to compile,
link, and run this program:
$ cc cpy.c
$ a.out
Use the following commands on IRIX systems to compile, link, and run
this program:
$ cc cpy.c -lffio
SSEEEE AALLSSOO
ffffrreeaadd(3C), ffffsseeeekk(3C)
aassggccmmdd(1)
ooppeenn(2) in the _U_N_I_C_O_S _S_y_s_t_e_m _C_a_l_l_s _R_e_f_e_r_e_n_c_e _M_a_n_u_a_l, publication
SR-2012
_A_p_p_l_i_c_a_t_i_o_n _P_r_o_g_r_a_m_m_e_r'_s _I/_O _G_u_i_d_e, publication SG-2168
_A_p_p_l_i_c_a_t_i_o_n _P_r_o_g_r_a_m_m_e_r'_s _L_i_b_r_a_r_y _R_e_f_e_r_e_n_c_e _M_a_n_u_a_l, publication
SR-2165, for the printed version of this man page.